from rest_framework import serializers
from .models import Areas

class AreaSerializer(serializers.ModelSerializer):
    #省的序列化器
    class Meta:
        model=Areas
        fields = ['id','name']

class SubsSerializer(serializers.ModelSerializer):
    '''
    详情视图使用的序列化器
    '''
    subs = AreaSerializer(many=True)
    class Meta:
        model = Areas
        fields = ['id','name','subs']